import { IToolTipItem } from "../../../../../com/mui/manager/IToolTipItem";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ToolTipsManager } from "../../../../../com/mui/manager/ToolTipsManager";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { _starCount } from "../../../../../this/_starCount";
type int = number;
//class StarPanel
    
    export  class StarPanel /* flash.display.Sprite */ implements IToolTipItem
    {
        constructor()
        {
            
            this._starArray = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=null;
            ObjCreate.createBg(0, 0, 200, 30, this, ImagesConst.Friend_over);
            var loc2=0;
            while (loc2 < this._amount) 
            {
                loc1 = new Object /* flash.display.Bitmap */(new Object /* flash.display.BitmapData */(22, 20, true, 16777215));
                loc1.width = 22;
                loc1.height = 20;
                loc1.x = loc2 * 25 + 15;
                loc1.y = 5;
                this.addChild(loc1);
                this._starArray.push(loc1);
                ++loc2;
            }
            ToolTipsManager.register(this);
            return;
        }

        public get toolTipData()
        {
            this._toolTipData = HTMLUtil.addColor(Language.getStringByParam(54170, this._num), GlobalStyle.color1);
            return this._toolTipData;
        }

        public set toolTipData(arg1)
        {
            return;
        }

        public get num(): int
        {
            return this._num;
        }

        public set num(arg1: int)
        {
            this._num = arg1;
            this.calStar();
            return;
        }

        /* internal  */calStar(): void
        {
            this._starCount = int(this._num / 100);
            this._isHaveHalfStar = this._num % 100 >= 50 ? true : false;
            this.updateStar();
            return;
        }

        /* internal  */updateStar(): void
        {
            LoaderHelp.addResCallBack(ResFileConst.petSkillRand, this.onUpdateStarHandler);
            return;
        }

        /* internal  */onClearStarHandler(): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._amount) 
            {
                loc1 = this._starArray[loc2];
                loc1.bitmapData = GlobalClass.getBitmapData(ImagesConst.StarEmpty);
                ++loc2;
            }
            return;
        }

        /* internal  */onUpdateStarHandler(): void
        {
            var loc1=null;
            this.onClearStarHandler();
            this._starCount = this._starCount > this._amount ? this._amount : _starCount;
            var loc2=0;
            while (loc2 < this._starCount) 
            {
                loc1 = this._starArray[loc2];
                loc1.bitmapData = GlobalClass.getBitmapData(ImagesConst.StarFill);
                ++loc2;
            }
            if (this._starCount < this._amount) 
            {
                if (this._isHaveHalfStar) 
                {
                    loc1 = this._starArray[this._starCount];
                    loc1.bitmapData = GlobalClass.getBitmapData(ImagesConst.StarHalf);
                }
            }
            return;
        }

        /* internal */ /* var */_toolTipData;

        /* internal */ /* var */_amount: int=7;

        /* internal */ /* var */_starArray: Array<any>;

        /* internal */ /* var */_num: int;

        /* internal */ /* var */_starCount: int;

        /* internal */ /* var */_isHaveHalfStar: Boolean;
    }
